var storage, fail, uid;
var default_theme   =   'theme-amethyst';
var is_first_load   =   true;
try {
    uid = new Date;
    (storage = window.localStorage).setItem(uid, uid);
    fail = storage.getItem(uid) != uid;
    storage.removeItem(uid);
    fail && (storage = false);
} catch (e) {
}
if (storage) {
    try {
        var usedSkin = $.cookie('config-skin');
        if (usedSkin != '' && usedSkin != null) {
            document.body.className = usedSkin;
        }
        else if(is_first_load){
            document.body.className = default_theme;
            writeStorage(storage, 'config-skin', default_theme);
            writeStorage(storage, "config-fixed-header", "fixed-header");
            writeStorage(storage, "config-fixed-footer", "fixed-footer");
            writeStorage(storage, "config-fixed-leftmenu", "fixed-leftmenu");
            is_first_load = false;
        }
    }
    catch (e) {
        document.body.className = default_theme;
    }
}
else {
    document.body.className = default_theme;
}